package Personajes;

import Objetos.*;
import java.io.Serializable;

public abstract class Personaje implements Serializable{

    protected double hp;
    protected double hpMax;
    protected int atk;
    protected int def;
    protected int[] armas = new int[2];
    protected int armadura;
    protected int tipo;
    public static final String tipos[] = {"ANGULO", "RABONA", "ARTILLERIA", "GRANJERO", "CIUDADANO", "INFANTERIA", "ARCABUCERO", "INFANTERIA DE ELITE", "FUSILERO DE ELITE"};
    public static final int num_distintos = 9;

    public Personaje(int hp, int atk, int def) {
        this.hp = hp;
        this.hpMax = hp;
        this.atk = atk;
        this.def = def;
    }

    public int getAtk() {
        int x = this.atk;
        if (this.armas[0] != -1) {
            x += Armeria.getArma(this.armas[0]).getAtk();
        }
        if (this.armas[1] != -1) {
            x += Armeria.getArma(this.armas[1]).getAtk() / 2;
        }
        return x;
    }

    public int getDef() {
        int x = this.def;
        if (this.armas[0] != -1) {
            x += Armeria.getArma(this.armas[0]).getDef() / 3;
        }
        if (this.armas[1] != -1) {
            x += Armeria.getArma(this.armas[1]).getDef() / 3;
        }
        if (this.armadura != -1) {
            x += Armeria.getArma(this.armadura).getDef();
        }
        return x;
    }

    public int curar(double factCuracion) {
        double newHP = (1 + factCuracion) * (this.hp);
        if (newHP > this.hpMax) {
            newHP = this.hpMax;
        }
        int dif = (int) (newHP - this.hp);
        this.hp = newHP;
        return dif;
    }

    public int get_tipo(){

        return this.tipo;
    }

}